<template>
  <div class="service">
    <h3>业务水平评价标准分值设定</h3>
    <hr />
    <el-form :model="serviceData" :inline="true" class="demo-form-inline">
      <el-col :span="12">
        <el-form-item
          label="近1年派遣单单量达到"
          prop="yearBusinsessSum"
          :rules="[
            { required: true, message: '内容不能为空' },
            { type: 'number', message: '内容必须为数字值' },
          ]"
        >
          <el-input
            v-model.number="serviceData.yearBusinsessSum"
            placeholder="请输入订单量达标数值"
            autocomplete="off"
            clearable
          ></el-input>
        </el-form-item>
        <span class="spanStyle">单</span>
      </el-col>
      <el-col :span="12">
        <el-form-item
          prop="yearBusinsessScoring"
          :rules="[
            { required: true, message: '内容不能为空' },
            { type: 'number', message: '内容必须为数字值' },
          ]"
        >
          <el-input
            v-model.number="serviceData.yearBusinsessScoring"
            placeholder="请输入分值"
            autocomplete="off"
            clearable
          ></el-input>
        </el-form-item>
        <span class="spanStyle">分</span>
      </el-col>

      <el-col :span="12">
        <el-form-item
          label="近1月派遣单单量达到"
          prop="monthBusinsessSum"
          :rules="[
            { required: true, message: '内容不能为空' },
            { type: 'number', message: '内容必须为数字值' },
          ]"
        >
          <el-input
            v-model.number="serviceData.monthBusinsessSum"
            placeholder="请输入订单量达标数值"
            autocomplete="off"
            clearable
          ></el-input>
        </el-form-item>
        <span class="spanStyle">单</span>
      </el-col>
      <el-col :span="12">
        <el-form-item
          prop="monthBusinsessScoring"
          :rules="[
            { required: true, message: '内容不能为空' },
            { type: 'number', message: '内容必须为数字值' },
          ]"
        >
          <el-input
            v-model.number="serviceData.monthBusinsessScoring"
            placeholder="请输入分值"
            autocomplete="off"
            clearable
          ></el-input>
        </el-form-item>
        <span class="spanStyle">分</span>
      </el-col>
      <el-form-item>
        <el-button type="primary" @click="serviceFun">确定</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { BusinessEvaluation, BasicInfoscore } from "@network/api/score.js";
export default {
  data() {
    return {
      serviceData: {
        monthBusinsessId: 17,
        monthBusinsessScoring: "",
        monthBusinsessSum: "",
        yearBusinsessId: 16,
        yearBusinsessScoring: "",
        yearBusinsessSum: "",
      },
    };
  },
  methods: {
    async serviceFun() {
      let resBusinessEvaluation = await BusinessEvaluation(this.serviceData);
      console.log("resBusinessEvaluation", resBusinessEvaluation);
      let { code } = resBusinessEvaluation.data;
      if (code && code == 200) {
        this.$message({
          message: "业务水平评价标准设置成功！",
          type: "success",
        });
      }
    },
    async BasicInfoFun() {
      let resBasicInfoscore = await BasicInfoscore();
      console.log(
        "resBasicInfoscore",
        resBasicInfoscore.data.data.allEvaluation
      );
      resBasicInfoscore.data.data.allEvaluation.forEach((item) => {
        switch (item.scoringId) {
          case 16:
            this.serviceData.yearBusinsessSum = Number(item.beiyong1) ;
            this.serviceData.yearBusinsessScoring = item.scoringScore;
            break;
          case 17:
            this.serviceData.monthBusinsessSum = item.beiyong2;
            this.serviceData.monthBusinsessScoring = item.scoringScore;
            break;
        }
      });
    },
  },
  created() {
    this.BasicInfoFun();
  },
};
</script>

<style>
.service {
  background-color: #fff;
  height: 100vh;
  padding: 40px 20px;
}
.spanStyle {
  margin-left: 3px;
  display: inline-block;
  height: 41px;
  line-height: 41px;
}
.demo-form-inline {
  margin-top: 30px;
}
</style>